package com.dyh.quickdemozwei.controller.http;

import com.alibaba.fastjson.JSON;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

public class JavaJsonHttpBody implements HttpBody {

	private Object obj = null;
	
	public JavaJsonHttpBody(Object obj) {
		this.obj = obj;
	}
	
	@Override
	public InputStream toInputStream(HttpContext context) {
		String s = JSON.toJSONString(obj);
		return new ByteArrayInputStream(s.getBytes(context.getCharset()));
	}

}
